Declare Function GetPrivateProfileString Lib "Kernel" (ByVal lpApplicationName As String, ByVal lpKeyname As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Integer, ByVal lpFileName As String) As Integer
Declare Function WritePrivateProfileString Lib "Kernel" (ByVal lpApplicationName As String, ByVal lpKeyname As String, ByVal lpstring As String, ByVal lplFileName As String) As Integer
Declare Function GetWindowsDirectory Lib "Kernel" (ByVal lpBuffer As String, ByVal nSize As Integer) As Integer
'global object variables
Global gCurrentDB As Database
Global gfDBOpenFlag As Integer
Global gCurrentDS As Dynaset
Global gCurrentTbl As Table
Global gCurrentQueryDef As QueryDef
Global gCurrentField As Field
Global gCurrentIndex As Index
Global gTableListSS As Snapshot
'global database variables
Global gstDataType As String
Global gstDBName As String
Global gstUserName As String
Global gstPassword As String
Global gstDataBase As String
Global gstDynaString As String
Global gstTblName As String
Global gfUpdatable As Integer
Global glQueryTimeout As Long
Global glLoginTimeout As Long
Global gstTableDynaFilter As String
Global gTblname As String ' used for filter and sort in grid and dynaset
'other global vars
Global gstZoomData As String
Global gwMaxGridRows As Long
Global gWindowsDirectory As String
Global gSQLUser As String
'new field properties
Global gwFldType As Integer
Global gwFldSize As Integer
Global gsumcolwid As Integer
'global find values
Global gfFindFailed As Integer
Global gstFindExpr As String
Global gstFindOp As String
Global gstFindField As String
Global gfFindMatch As Integer
Global gfFromTableView As Integer
' global filter values
Global gFilterStr As String
' global sort values
Global gSortStr As String
' Global flag for stored queries
Global gStoredFlag As Integer
'global seek values
Global gstSeekOperator As String
Global gstSeekValue As String
'global flags
Global gfDBChanged As Integer
Global gfFROMSQL As Integer
Global gfTransPending As Integer
Global gfAddTableFlag As Integer
'global constants
Global Const DEFAULTDRIVER = "SQL Server"
Global Const MODAL = 1
Global Const HOURGLASS = 11
Global Const DEFAULT_MOUSE = 0
Global Const YES = 6
Global Const MSGBOX_TYPE = 4 + 48 + 256
Global Const TRUE_ST = "True"
Global Const FALSE_ST = "False"
Global Const EOF_ERR = 626
Global Const FTBLS = 0
Global Const FFLDS = 1
Global Const FINDX = 2
Global Const MAX_GRID_ROWS = 31999
Global Const MAX_MEMO_SIZE = 20000
Global Const GETCHUNK_CUTOFF = 50
Global Const MB_YESNOCANCEL = 3
Global Const MB_YESNO = 4
Global Const MB_ICONSTOP = 16
Global Const MB_ICONQUESTION = 32
Global Const MB_ICONEXCLAMATION = 48
Global Const MB_ICONINFORMATION = 64
Global Const MB_DEFBUTTON2 = 256
Global Const IDYES = 6
Global Const IDNO = 7
' Define other.
'field type constants
Global Const FT_TRUEFALSE = 1
Global Const FT_BYTE = 2
Global Const FT_INTEGER = 3
Global Const FT_LONG = 4
Global Const FT_CURRENCY = 5
Global Const FT_SINGLE = 6
Global Const FT_DOUBLE = 7
Global Const FT_DATETIME = 8
Global Const FT_STRING = 10
Global Const FT_BINARY = 11
Global Const FT_MEMO = 12
'table type constants
Global Const DB_TABLE = 1
Global Const DB_ATTACHEDTABLE = 6
Global Const DB_ATTACHEDODBC = 4
Global Const DB_QUERYDEF = 5
Global Const DB_SYSTEMOBJECT = &H80000002
'dynaset option parameter constants
Global Const VBDA_DENYWRITE = &H1
Global Const VBDA_DENYREAD = &H2
Global Const VBDA_READONLY = &H4
Global Const VBDA_APPENDONLY = &H8
Global Const VBDA_INCONSISTENT = &H10
Global Const VBDA_CONSISTENT = &H20
Global Const VBDA_SQLPASSTHROUGH = &H40
'db create/compact constants
Global Const DB_CREATE_GENERAL = ";langid=0x0809;cp=1252;country=0"
Global Const DB_VERSION10 = 1
' Microsoft Access QueryDef types
Global Const DB_QACTION = &HF0
Global Const DB_QCROSSTAB = &H10
Global Const DB_QDELETE = &H20
Global Const DB_QUPDATE = &H30
Global Const DB_QAPPEND = &H40
Global Const DB_QMAKETABLE = &H50
' Index Attributes
Global Const DB_UNIQUE = 1
Global Const DB_PRIMARY = 2
Global Const DB_PROHIBITNULL = 4
Global Const DB_IGNORENULL = 8
Global Const DB_DESCENDING = 1 'For each field in Index
Function ActionQueryType (qn As String) As String
Dim i As Integer
gTableListSS.MoveFirst
While gTableListSS.EOF = False And gTableListSS!Name <> qn
gTableListSS.MoveNext
Wend
If gTableListSS!Name = qn Then
Select Case gTableListSS!Attributes
Case DB_QCROSSTAB
ActionQueryType = "Cross Tab"
Case DB_QDELETE
ActionQueryType = "Delete"
Case DB_QUPDATE
ActionQueryType = "Update"
Case DB_QAPPEND
ActionQueryType = "Append"
Case DB_QMAKETABLE
ActionQueryType = "Make Table"
End Select
Else
ActionQueryType = ""
End If
End Function
Sub ExecSql ()
Dim RetSQL As Long
If Not gStoredFlag Then ' flag goes here
If fQuery!cCriteria = "" Then ' no sql statment
gfFROMSQL = False
Exit Sub
End If
Else
gfFROMSQL = False
ResetMouse fQuery
MsgBar "", False
'gStoredFlag = False
If fQuery!Option1(0) = False Then
Dim dsform1 As New fDynaset
dsform1.Show
Else
Dim dsform2 As New fGridFrm
dsform2.Show
End If
Exit Sub
End If
MsgBar "Executing SQL Statement", True
'SetHourGlass Me
If UCase(Mid(fQuery!cCriteria, 1, 6)) = "SELECT" And InStr(UCase(fQuery!cCriteria), " INTO ") = 0 Then
On Error GoTo SQLDSErr
MakeDynaset:
gfFROMSQL = True
'create a new dynaset form
gstDynaString = ""
On Error GoTo SQLDSErr
If fQuery!Option1(0) = False Then
Dim dsform3 As New fDynaset
dsform3.Show
Else
Dim dsform4 As New fGridFrm
dsform4.Show
End If
On Error GoTo SQLErr
End If
GoTo SQLEnd
SQLErr:
If Err = 3065 Then 'row returning so try to create dynaset